var orderId = sessionStorage.getItem("orderId");
console.log(orderId);

var orderData = {
    order_id: orderId
};
var succCallBack = function (data, status, response) {
    if (data.errorCode == 0) {
        console.log(data.data)
        var obj = data.data;
        if (obj.invoice_status == 40) {
            $("#invoice_status").html('已开');
        }else if (obj.invoice_status == 50) {
            $("#invoice_status").html('已发');
        }

        if (obj.invoice_type == 10) {
            $("#invoice_type").html('增值税');
            $("#registeredAddress").html(obj.register_address);
            $("#registeredTelehone").html(obj.register_phone);
            $("#depositBank").html(obj.open_bank);
            $("#bankAccount").html(obj.bank_account);
        } else if (obj.invoice_type == 20) {
            $("#invoice_type").html('普税');
            $('.added_value').each(function (i){
                // i就是索引值
                // this 表示获取遍历每一个dom对象
                $(this).hide();
            });
        } else if (obj.invoice_type == 30) {
            $("#invoice_type").html('未选择发票');
            $('.added_value').each(function (i){
                $(this).hide();
            });
        }
        $("#remarks").html(obj.invoice_remark);
        $("#submit_time").html(obj.create_date);
        $("#invoice_title").html(obj.invoice_title);
        if (obj.invoice_title == "个人") {
            $("#isShow").hide();
        }
        $("#taxpayer_identify_num").html(obj.taxpayer_identify_num);
        $("#addressArea").html(obj.province_name + obj.city_name + obj.area_name + obj.town_name);
        $("#detail_address").html(obj.detail_address);
        $("#received_name").html(obj.received_name);
        $("#received_phone").html(obj.received_phone);
        $("#logistics_company").val(obj.logistics_company);
        $("#logistics_num").val(obj.logistics_num);

    }
}
web.doAjax(root.orderInter.order_queryInoviceDetails, 'post', orderData, succCallBack);


function save() {
    $.ajax({
        contentType: 'application/json',
        url: root.orderInter.order_updateInoviceLogistics,
        cache: false, //禁用缓存
        type: "POST",
        data: JSON.stringify({
            order_id: orderId,
            logistics_company: $("#logistics_company").val(),
            logistics_num: $("#logistics_num").val(),
        }),
        success: function (data) {
            if (data.errorCode == 0) {
                console.log(data)
                layer.msg("保存成功",{icon: 6,time:1000},function () {
                    var index =  parent.location.reload();
                    parent.layer.close(index);
                });
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {}
    });
}